package com.wind.stream;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Stream的使用：过滤
 *
 * @author Wind
 * @date 2021-06-06
 */
public class Test03Stream {
    public static void main(String[] args) {

        List<Person> list = new ArrayList<>();
        list.add(new Person("张三", 7000, 34, "男", "陕西"));
        list.add(new Person("李四", 8000, 24, "男", "河北"));
        list.add(new Person("王五", 6000, 42, "女", "甘肃"));
        list.add(new Person("王五", 9000, 12, "女", "上海"));

        // 工资大于等于8000 并返回新的集合
        List<Person> collect = list.stream().filter(t -> t.getSalary() >= 8000).collect(Collectors.toList());
        System.out.println(collect);
    }
}
